import axios, {ResponseData} from 'yuxin-base/src/utils/axios'
enum Api {
  // 添加个人客户
  PostSaasRentalCustomerLedgerCustomerPersonalAdd = '/saas-rental-customer/ledger/customer/personal/add',
  // 添加企业客户
  PostSaasRentalCustomerLedgerCustomerEnterpriseAdd = '/saas-rental-customer/ledger/customer/enterprise/add',
  // 编辑个人客户
  PutSaasRentalCustomerLedgerCustomerPersonal = '/saas-rental-customer/ledger/customer/personal',
  // 编辑企业客户
  PutSaasRentalCustomerLedgerCustomerEnterprise = '/saas-rental-customer/ledger/customer/enterprise',
  // 删除客户
  DelSaasRentalCustomerLedgerCustomer = '/saas-rental-customer/ledger/customer',
  // 添加客户的联系人
  PostSaasRentalCustomerLedgerCustomerContactAdd = '/saas-rental-customer/ledger/customer',
  // 编辑客户的联系人
  PutSaasRentalCustomerLedgerCustomerContact = '/saas-rental-customer/ledger/customer',
  //   删除客户的联系人
  DelSaasRentalCustomerLedgerCustomerContact = '/saas-rental-customer/ledger/customer',
  //   客户台账隐私信息解密
  PostSaasRentalCustomerLedgerCustomerDecryptionData = '/saas-rental-customer/ledger/customer/decryptionData',
  //   客户台账列表
  GetSaasRentalCustomerLedgerCustomerList = '/saas-rental-customer/ledger/customer/list',
  //   客户台账详情
  GetSaasRentalCustomerLedgerCustomer = '/saas-rental-customer/ledger/customer'
}

/**
 * 获取部门树和人
 * @param
 * @returns
 */
export const getDeptTrees = (): Promise<ResponseData> => {
  return axios.request({
    url: '/saas-rental-uaa/uaa/department/list',
    method: 'GET'
  })
}

// 添加个人客户
export const PostSaasRentalCustomerLedgerCustomerPersonalAdd = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: Api.PostSaasRentalCustomerLedgerCustomerPersonalAdd,
    data,
    method: 'POST'
  })
}
// 添加企业客户
export const PostSaasRentalCustomerLedgerCustomerEnterpriseAdd = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: Api.PostSaasRentalCustomerLedgerCustomerEnterpriseAdd,
    data,
    method: 'POST'
  })
}
// 编辑个人客户
export const PutSaasRentalCustomerLedgerCustomerPersonal = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.PutSaasRentalCustomerLedgerCustomerPersonal}/${data.customerId}`,
    data,
    method: 'PUT'
  })
}
// 编辑企业客户
export const PutSaasRentalCustomerLedgerCustomerEnterprise = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.PutSaasRentalCustomerLedgerCustomerEnterprise}/${data.customerId}`,
    data,
    method: 'PUT'
  })
}
// 删除客户
export const DelSaasRentalCustomerLedgerCustomer = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.DelSaasRentalCustomerLedgerCustomer}/${data.customerId}`,
    data,
    method: 'DELETE'
  })
}
// 添加客户的联系人
export const PostSaasRentalCustomerLedgerCustomerContactAdd = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.PostSaasRentalCustomerLedgerCustomerContactAdd}/${data.customerId}/contact/add`,
    data,
    method: 'POST'
  })
}
// 编辑客户的联系人
export const PutSaasRentalCustomerLedgerCustomerContact = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.PutSaasRentalCustomerLedgerCustomerContact}/${data.customerId}/contact/${data.contactId}`,
    data,
    method: 'PUT'
  })
}
// 编辑客户的联系人
export const DelSaasRentalCustomerLedgerCustomerContact = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.DelSaasRentalCustomerLedgerCustomerContact}/${data.customerId}/contact/${data.contactId}`,
    data,
    method: 'DELETE'
  })
}
// 客户台账隐私信息解密
export const PostSaasRentalCustomerLedgerCustomerDecryptionData = (data: any): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.PostSaasRentalCustomerLedgerCustomerDecryptionData}`,
    data,
    method: 'POST'
  })
}
// 客户台账列表
export const GetSaasRentalCustomerLedgerCustomerList = (params?): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.GetSaasRentalCustomerLedgerCustomerList}`,
    params,
    method: 'GET'
  })
}
// 客户台账详情
export const GetSaasRentalCustomerLedgerCustomer = (params?): Promise<ResponseData> => {
  return axios.request({
    url: `${Api.GetSaasRentalCustomerLedgerCustomer}/${params.customerId}`,
    params,
    method: 'GET'
  })
}
//删除客户开票信息
export const delInvoiceInfos = (customerId,invoiceId): Promise<ResponseData> => {
  return axios.request({
    url: `/saas-rental-customer/ledger/customer/${customerId}/invoice/${invoiceId}`,
    method: 'DELETE'
  })
}
//编辑保存客户信息
export const saveInvoiceInfos = (customerId,invoiceId,data): Promise<ResponseData> => {
  return axios.request({
    url: `saas-rental-customer/ledger/customer/${customerId}/invoice/${invoiceId}`,
    data,
    method: 'put'
  })
}
//新增客户信息
export const addInvoiceInfos = (customerId,data): Promise<ResponseData> => {
  return axios.request({
    url: `saas-rental-customer/ledger/customer/${customerId}/invoice/add`,
    data,
    method: 'post'
  })
}
//新增银行账号
export const addBankAccounts = (customerId,data): Promise<ResponseData> => {
  return axios.request({
    url: `/saas-rental-customer/ledger/customer/${customerId}/bankAccount/add`,
    data,
    method: 'post'
  })
}
//编辑客户的银行账号
export const editBankAccounts = (customerId,bankAccountId,data): Promise<ResponseData> => {
  return axios.request({
    url: `/saas-rental-customer/ledger/customer/${customerId}/bankAccount/${bankAccountId}`,
    data,
    method: 'put'
  })
}
//删除客户的银行账号
export const delBankAccounts = (customerId,bankAccountId): Promise<ResponseData> => {
  return axios.request({
    url: `/saas-rental-customer/ledger/customer/${customerId}/bankAccount/${bankAccountId}`,
    method: 'DELETE'
  })
}